]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Update WorkspaceLayout workarea on changes
authorSebastian Keller <skeller@gnome.org>
Tue, 16 Mar 2021 20:26:33 +0000 (21:26 +0100)
committerSebastian Keller <skeller@gnome.org>
Tue, 11 May 2021 00:36:54 +0000 (02:36 +0200)
Previously the workarea was only set on construction and then never
updated. As a result the preferred width and height as well as the
allocation were based on an outdated workarea size when it changed after
construction. This for example was happening during the startup
animation, for which the WorkspaceLayout is constructed before the panel
is shown. This caused the workspace in the overview to be slightly
smaller when it is first shown and the overview closing animation to
not expand the workspace to the correct size the first time it is
closed.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3945
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3816

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1771>

js/ui/workspace.js

index f8b0d40ed285b26ec92c656a1dba1b18c570c41c..75efe4d992e41859d86fd6b35a26e7b7afc1ee4c 100644 (file)
@@ -413,9 +413,6 @@ var WorkspaceLayout = GObject.registerClass({
 
         this._metaWorkspace = metaWorkspace;
         this._monitorIndex = monitorIndex;
-        this._workarea = metaWorkspace
-            ? metaWorkspace.get_work_area_for_monitor(this._monitorIndex)
-            : Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
         this._overviewAdjustment = overviewAdjustment;
 
         this._container = null;
@@ -435,6 +432,9 @@ var WorkspaceLayout = GObject.registerClass({
             this.syncOverlays();
             this.layout_changed();
         });
+
+        this._workarea = null;
+        this._workareasChangedId = 0;
     }
 
     _isBetterScaleAndSpace(oldScale, oldSpace, scale, space) {
@@ -563,8 +563,25 @@ var WorkspaceLayout = GObject.registerClass({
         return workarea;
     }
 
+    _syncWorkareaTracking() {
+        if (this._container) {
+            if (this._workAreaChangedId)
+                return;
+            this._workarea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
+            this._workareasChangedId =
+                global.display.connect('workareas-changed', () => {
+                    this._workarea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
+                    this.layout_changed();
+                });
+        } else if (this._workareasChangedId) {
+            global.display.disconnect(this._workareasChangedId);
+            this._workareasChangedId = 0;
+        }
+    }
+
     vfunc_set_container(container) {
         this._container = container;
+        this._syncWorkareaTracking();
         this._stateAdjustment.actor = container;
     }